<template>
	<view class="cart-container">
		<view class="cart-title">
			<uni-icons type="shop" size="18"></uni-icons>
			
			<text class="cart-title-text">购物车</text>
		</view>
		
		
			
		
		
		<uni-swipe-action>
			<block v-for="(goods,i) in cart" :key="i">
			<uni-swipe-action-item :right-options="options" @click="swipeItemClickHandler(goods)">
				<my-goods :goods="goods" @radio-change="radioChangeHandler"></my-goods>
			</uni-swipe-action-item>
			</block>
		</uni-swipe-action>
		
		<my-settle></my-settle>
		
		
		
		
		
		
		
	</view>
</template>

<script>
import badgeMix from '@/mixins/tabbar-badge.js'
import {mapState,mapMutations} from 'vuex'
	
	export default {
		mixins:[badgeMix],
		computed:{
			...mapState('m_cart',['cart']),
		},
		

		
		data() {
			return {
				options:[{
					text:'删除',
					style:{
						backgroundColor:'#C00000'
					}
				}]
				
			};
		},
		methods:{
			...mapMutations('m_cart',['updateGoodsState','removeGoodsById']),
			radioChangeHandler(e){
				this.updateGoodsState(e)
				
			},
			swipeItemClickHandler(goods){
				this.removeGoodsById(goods.goods_id)
			}
		}

	}
</script>

<style lang="scss">
	.cart-container{
		padding-bottom: 50px;
	}
.cart-title{
	height: 40px;
	display: flex;
	align-items: center;
	padding-left: 5px;
	border-bottom: 1px solid #EFEFEF;
	
	.cart-title-text{
		font-size: 14px;
		margin-left: 10px;
		
	}
}

</style>
